package util.webSearch.wrapper;

import java.util.HashSet;
import java.util.Iterator;

import util.io.FileInput;
import util.webSearch.DeliciousQuery;
import util.webSearch.DeliciousURLInfo;


public class DeliciousExperiments  {

	/**
	 * @param args
	 */
	
	
	
	public static void printURLTags(HashSet<String>set, int min_freq ){
		
		
		Iterator<String> iter = set.iterator();
		
		
		while(iter.hasNext()){
			
			String url = iter.next();
			
			DeliciousURLInfo post = DeliciousQuery.getDeliciousURLInfo(url);		
			System.out.println(post.getUrl()+"\t"+ post.getTagsRaw(min_freq));
			
			
			
		}
		
	}

	public static void printURLTags(String url, int min_freq) {

		DeliciousURLInfo post = DeliciousQuery.getDeliciousURLInfo(url);
		if(post!=null)
		System.out.println(post.getUrl() + "\t" + post.getTagsFrequency());

	}
	
	
	public static void createSimpleDict(){
		
		
	}
	
	public static void getDMOZTags(String file, int min_freq) {

		FileInput in = new FileInput(file);

		String line = in.readString();

		while (line != null) {

		
		
			
			  //do what you want to do before sleeping
			  try {
				  
					printURLTags(line, min_freq);
				Thread.currentThread().sleep(2000);
				
				line = in.readString();
			} catch (InterruptedException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}//sleep for 1000 ms

		
			

		
		}

	}
	
	
	
	public static void main(String[] args) {
		
		String path = "/home/sergio/projects/data/dmoz/kt/dmoz_kids_urls.txt";
		getDMOZTags(path,0);
		
		
	}

}
